package com.platform.modules.prj.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.common.enumstatus.AptitudeEnum;
import com.platform.common.enumstatus.SystemEnum;
import com.platform.common.exception.BusinessException;
import com.platform.common.utils.Query;
import com.platform.modules.prj.dao.PrjProjectDao;
import com.platform.modules.prj.entity.PrjProjectEntity;
import com.platform.modules.prj.service.PrjProjectService;
import com.platform.modules.prj.vo.ProjectPersonnel;
import com.platform.modules.prj.vo.ProjectPersonnelVo;
import com.platform.modules.quality.vo.CommonResult;
import com.platform.modules.sys.entity.SysUserEntity;
import com.platform.modules.sys.service.SysDeptService;
import com.platform.modules.sys.service.SysUserService;

import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

/**
 * Service实现类
 *
 * @author Zhouxw
 * @date 2019-06-20 17:17:28
 */
@Service("prjProjectService")
public class PrjProjectServiceImpl extends ServiceImpl<PrjProjectDao, PrjProjectEntity> implements PrjProjectService {

	
	@Autowired
	SysDeptService sysDeptService;
	
	@Autowired
	SysUserService sysUserService;
	
	
	
    @Override
    @Deprecated
    public List<PrjProjectEntity> queryAll(Map<String, Object> params) {
        return baseMapper.queryAll(params);
    }

    @Override
    public IPage<PrjProjectEntity> queryPage(Map<String, Object> params) {
        //排序
        params.put("sidx", "T.CREATE_TIME");
        params.put("asc", false);
        IPage<PrjProjectEntity> page = new Query<PrjProjectEntity>(params).getPage();
        List<PrjProjectEntity> list = baseMapper.selectPrjProjectPage(page, params);
        return page.setRecords(list);
    }
    
    
    @Override
    public Page queryPrjSuperviseProjectPage(Map<String, Object> params) {
        //排序
        params.put("sidx", "T.CREATE_TIME");
        params.put("asc", false);
        Page<PrjProjectEntity> page = new Query<PrjProjectEntity>(params).getPage();
        List<PrjProjectEntity> list = baseMapper.selectPrjSuperviseProjectPage(page, params);
        return page.setRecords(list);
    }
    
    

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean add(PrjProjectEntity prjProject) {
        //生成唯一项目编号
        String prjCode;
        String countyNum = prjProject.getCountyNum();
        DateFormat df = new SimpleDateFormat("yyMMdd");
        String dateStr = df.format(new Date());
        String code = queryPrjCode(countyNum + dateStr);
        if (StringUtils.isNotBlank(code)) {
            long l = Long.parseLong(code);
            prjCode = ++l + "";
        } else {
            prjCode = countyNum + dateStr + "0001";
        }
        prjProject.setPrjCode(prjCode);
        prjProject.setDeclareStatus("0");
        
        //保存成功
        if(this.save(prjProject)) {
        	sysDeptService.createRootDept(prjProject.getPrjName(),prjProject.getPrjId());
        	this.createProjectGLY(prjProject.getPrjId());
        }
        
        return true;
    }
  
    
    @Override
   	public void createProjectGLY(String prjId) {
       	PrjProjectEntity prjProject = this.getById(prjId);
       	SysUserEntity user = new SysUserEntity();
       	//项目管理员 role_id
       	user.setUserName(prjProject.getPrjCode());
       	user.setRealName(prjProject.getPrjName());
       	user.setRoleIdList(Arrays.asList("f01c73757a56e9f58780b260cdbf4ce2"));
       	user.setStatus(AptitudeEnum.aptitudeStatus.YBSYPZ.getKey());              //审核中状态（此处为启用状态）
		user.setAccountType(SystemEnum.accountType.ORG.getKey());                //注册机构的人员账号类型默认为企业账号
		user.setOrgNo(prjId);
       	sysUserService.addUser(user, null);   		
   	}
       
    
    
    

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean update(PrjProjectEntity prjProject) {
        return this.updateById(prjProject);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean delete(String id) {
        return this.removeById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteBatch(String[] ids) {
        return this.removeByIds(Arrays.asList(ids));
    }

    @Override
    public String queryPrjCode(String prjCode) {
        return baseMapper.queryPrjCode(prjCode);
    }

	@Override
	public List<SysUserEntity> projectManagerByApp(String prjId) {
		//不确定是否有多个项目经理的情况
		return baseMapper.projectManagerByApp(prjId);
	}

	@Override
	public List<ProjectPersonnelVo> projectPersonnelByApp(String prjId) {
		List<ProjectPersonnelVo> list = new LinkedList<ProjectPersonnelVo>();
		PrjProjectEntity projectEntity = baseMapper.selectById(prjId);
		if(null==projectEntity) {
			throw new BusinessException("未找到项目");
		}
		
		//查询建设单位及下分配项目的人员信息
		ProjectPersonnelVo jsdw = new ProjectPersonnelVo();
		jsdw.setOrgNo(projectEntity.getBuildCorpId());
		jsdw.setOrgName(projectEntity.getBuildCorpName());
		jsdw.setOrgType("1");
		List<ProjectPersonnel> personnels = baseMapper.orgPersonnels(prjId, projectEntity.getBuildCorpId());
		jsdw.setPersonnel(personnels);
		list.add(jsdw);
		
		//TODO 监理单位
		ProjectPersonnelVo jldw = new ProjectPersonnelVo();
		jldw.setOrgName("监理单位");
		jldw.setOrgNo("");
		jldw.setOrgType("5");
		list.add(jldw);
		
		//查询施工单位及下分配项目的人员信息
		ProjectPersonnelVo sgdw = new ProjectPersonnelVo();
		sgdw.setOrgNo(projectEntity.getSgCorpId());
		sgdw.setOrgName(projectEntity.getSgCorpName());
		sgdw.setOrgType("9");
		List<ProjectPersonnel> sgPersonnels = baseMapper.orgPersonnels(prjId, projectEntity.getSgCorpId());
		sgdw.setPersonnel(sgPersonnels);
		list.add(sgdw);
		
		//查询项目单位及下分配项目的人员信息
		ProjectPersonnelVo xmdw = new ProjectPersonnelVo();
		xmdw.setOrgNo(projectEntity.getPrjId());
		xmdw.setOrgName(projectEntity.getPrjName());
		xmdw.setOrgType("10");
		List<ProjectPersonnel> xmPersonnels = baseMapper.orgPersonnels(null, prjId);
		xmdw.setPersonnel(xmPersonnels);
		list.add(xmdw);
		
		return list;
	}

	@Override
	public PrjProjectEntity infoByApp(String prjId) {
		PrjProjectEntity prjProject = baseMapper.selectById(prjId);
        if(null==prjProject) {
            return null;
        }
        //查询 建设单位 项目负责人
        if(StringUtils.isNotBlank(prjProject.getBuildCorpId())) {
        	SysUserEntity user = baseMapper.projectLeaderByOrg(prjProject.getBuildCorpId(), prjProject.getPrjId(), "ROLE_JS_XMFZR");
        	if(null!=user) {
            	prjProject.setBuildProjectLeaderId(user.getUserId());
            	prjProject.setBuildProjectLeaderName(user.getRealName());
        	}
        }
        //查询 施工单位 项目负责人
        if(StringUtils.isNotBlank(prjProject.getSgCorpId())) {
        	SysUserEntity user = baseMapper.projectLeaderByOrg(prjProject.getSgCorpId(), prjProject.getPrjId(), "ROLE_SG_XMFZR");
        	if(null!=user) {
            	prjProject.setSgProjectLeaderId(user.getUserId());
            	prjProject.setSgProjectLeaderName(user.getRealName());
        	}
        }
        //查询 监理单位 项目负责人
        if(StringUtils.isNotBlank(prjProject.getJlCorpId())) {
        	SysUserEntity user = baseMapper.projectLeaderByOrg(prjProject.getJlCorpId(), prjProject.getPrjId(), "ROLE_JL_XMFZR");
        	if(null!=user) {
            	prjProject.setJlProjectLeaderId(user.getUserId());
            	prjProject.setJlProjectLeaderName(user.getRealName());
        	}
        }
        //查询 勘察单位 项目负责人
        if(StringUtils.isNotBlank(prjProject.getKcCorpId())) {
        	SysUserEntity user = baseMapper.projectLeaderByOrg(prjProject.getKcCorpId(), prjProject.getPrjId(), "ROLE_KC_XMFZR");
        	if(null!=user) {
            	prjProject.setKcProjectLeaderId(user.getUserId());
            	prjProject.setKcProjectLeaderName(user.getRealName());
        	}
        }
        //查询 设计单位 项目负责人
        if(StringUtils.isNotBlank(prjProject.getSjCorpId())) {
        	SysUserEntity user = baseMapper.projectLeaderByOrg(prjProject.getSjCorpId(), prjProject.getPrjId(), "ROLE_SJ_XMFZR");
        	if(null!=user) {
            	prjProject.setSjProjectLeaderId(user.getUserId());
            	prjProject.setSjProjectLeaderName(user.getRealName());
        	}
        }
        //查询 审图单位 项目负责人
        if(StringUtils.isNotBlank(prjProject.getStCorpId())) {
        	SysUserEntity user = baseMapper.projectLeaderByOrg(prjProject.getStCorpId(), prjProject.getPrjId(), "ROLE_ST_XMFZR");
        	if(null!=user) {
            	prjProject.setStProjectLeaderId(user.getUserId());
            	prjProject.setStProjectLeaderName(user.getRealName());
        	}
        }
        //查询 检测单位 项目负责人
        if(StringUtils.isNotBlank(prjProject.getJcCorpId())) {
        	SysUserEntity user = baseMapper.projectLeaderByOrg(prjProject.getJcCorpId(), prjProject.getPrjId(), "ROLE_JC_XMFZR");
        	if(null!=user) {
            	prjProject.setJcProjectLeaderId(user.getUserId());
            	prjProject.setJcProjectLeaderName(user.getRealName());
        	}
        }
        //查询 预拌混凝土单位 项目负责人
        if(StringUtils.isNotBlank(prjProject.getYbhntCorpId())) {
        	SysUserEntity user = baseMapper.projectLeaderByOrg(prjProject.getYbhntCorpId(), prjProject.getPrjId(), "ROLE_YBHNT_XMFZR");
        	if(null!=user) {
            	prjProject.setYbhntProjectLeaderId(user.getUserId());
            	prjProject.setYbhntProjectLeaderName(user.getRealName());
        	}
        }
        
        //prjCategory
        //工程项目类别
        //PRJ_CATEGORY : [{"code":"PRJ_CATEGORY","childrens":[{"name":"房建工程","dictId":"1985419dfc0fe64ff7e1ad1ecbfe6eb9","value":"01"},{"name":"市政工程","dictId":"13576485b09261954996efd063d808ae","value":"02"}],"groupId":"21ec156e3319f3a3d4175bc6f0ae95d3","name":"工程项目类别"}],
        if(StringUtils.isNotBlank(prjProject.getPrjCategory())) {
        	if("01".equals(prjProject.getPrjCategory())) {
        		prjProject.setPrjCategory("房建工程");
        	}else if("02".equals(prjProject.getPrjCategory())) {
        		prjProject.setPrjCategory("市政工程");
        	}
        }
        
        //prjQuality
        //建设性质分类
        //PRJ_PROPERTY : [{"code":"PRJ_PROPERTY","childrens":[{"name":"新建","dictId":"9d352e0788b76491bb16b960beba8d61","value":"001"},
//        {"name":"改建","dictId":"92e234b9b98ade3b0994fe58a4639dde","value":"002"},
//        {"name":"扩建","dictId":"177ab86c976cd366753d5141043846de","value":"003"},
//        {"name":"恢复","dictId":"92b3b65544d7275156786743fa559146","value":"004"},
//        {"name":"迁建","dictId":"725dfc79144efac61b1f1ee1be004c77","value":"005"},
//        {"name":"拆除","dictId":"99df8e610ec14f0ef1bfe3b6b2306040","value":"006"},
//        {"name":"其他","dictId":"9826007ebd3e580c75ce4429a816d391","value":"099"}],"groupId":"0e0e82b1588ea20f535b1f93d408e5a2","name":"建设性质分类"}],
        if(StringUtils.isNotBlank(prjProject.getPrjQuality())) {
        	if("001".equals(prjProject.getPrjQuality())) {
        		prjProject.setPrjQuality("新建");
        	}else if("002".equals(prjProject.getPrjQuality())) {
        		prjProject.setPrjQuality("改建");
        	}else if("003".equals(prjProject.getPrjQuality())) {
        		prjProject.setPrjQuality("扩建");
        	}else if("004".equals(prjProject.getPrjQuality())) {
        		prjProject.setPrjQuality("恢复");
        	}else if("005".equals(prjProject.getPrjQuality())) {
        		prjProject.setPrjQuality("迁建");
        	}else if("006".equals(prjProject.getPrjQuality())) {
        		prjProject.setPrjQuality("拆除");
        	}else if("099".equals(prjProject.getPrjQuality())) {
        		prjProject.setPrjQuality("其他");
        	}
        }
        
        //prjPurpose
        //工程用途
        //PRJ_FUNCTION : [{"code":"PRJ_FUNCTION","childrens":[{"name":"居住建筑","dictId":"266b0f503f95777438b656c0dff1fd8e","value":"100"},
//        {"name":"居住建筑配套工程","dictId":"dffa12a6e65797b372c91e91de6c2c68","value":"200"},
//        {"name":"公共建筑","dictId":"ce8d6316d11390c1dc9b0be617058218","value":"300"},
//        {"name":"办公建筑","dictId":"1989f197546d2896a624fab81605bf2a","value":"301"},
//        {"name":"商业建筑","dictId":"acd21e2d241b4fac90bb21a2db65a3e6","value":"302"},
//        {"name":"旅游建筑","dictId":"c93963d83bd72f520da2a39719becb5f","value":"303"},
//        {"name":"科教文卫建筑","dictId":"63496ff23f5a4d7fd3b5409d7c84dfc2","value":"304"},
//        {"name":"交通运输类","dictId":"5b242bdfabc83948c214d2dc2768c632","value":"305"},
//        {"name":"通信建筑","dictId":"c2bae68df906a3a770b2fa03689f4065","value":"306"},
//        {"name":"公共建筑配套工程","dictId":"25fe0a30a6285f6c1ccf2f553e87bf72","value":"307"},
//        {"name":"商住楼","dictId":"81003b38ee2c411158cd1f485335411c","value":"400"},
//        {"name":"农业建筑","dictId":"251c7437bba08b4d58ee1d32a4739c26","value":"500"},
//        {"name":"农业建筑配套工程","dictId":"c48c076c26e29b8c8939b9e5686c32e4","value":"600"},
//        {"name":"工业建筑","dictId":"1ce2ff473afcff4df2ac15610f86930c","value":"700"},
//        {"name":"工业建筑配套工程","dictId":"3ad83132a66dcb9b46fd32d8d6b6f0d2","value":"800"},
//        {"name":"其他","dictId":"8b5e0ccc4ccce730f1f7720ebe5efc96","value":"999"},
//        {"name":"给水","dictId":"cacb53e0172197f50337ec85222ab64c","value":"010"},
//        {"name":"排水","dictId":"abc5393cb7a233bf43a18fb3ae5e27c5","value":"011"},
//        {"name":"燃气","dictId":"1455f4867c19e088adfdb5eda444fd3e","value":"012"},
//        {"name":"热力","dictId":"5257873f9028d1409d30f77df27b502f","value":"013"},
//        {"name":"道路","dictId":"f153849eed6be4295f2fec9c6fc949a2","value":"014"},
//        {"name":"桥梁","dictId":"b75959efce4eedf8d8997e45f11cf5d7","value":"015"},
//        {"name":"园林绿化","dictId":"9340765ee75ee6d7cdf55c9515f87b01","value":"016"},
//        {"name":"环境卫生","dictId":"cf5b89f3b56bb375f027a3ef60391487","value":"017"},
//        {"name":"公共交通","dictId":"c6d1c42de2e3df073437465d93466b03","value":"018"},
//        {"name":"综合管廊","dictId":"96b38f54898df52878faee404fc00b9a","value":"019"},
//        {"name":"隧道","dictId":"a81af866bcb1a38852c9fefdea3cbb6e","value":"020"},
//        {"name":"轨道交通","dictId":"5373ac595a1463032a43a8baea74b96f","value":"021"},
//        {"name":"其他","dictId":"a8ac8c50b78eb2840d55efa004bbc7cd","value":"099"}],"groupId":"a087920f8ad31a1c3fc4c88a149312d8","name":"工程用途"}],
        if(StringUtils.isNotBlank(prjProject.getPrjPurpose())) {
        	if("100".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("居住建筑");
        	}else if("200".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("居住建筑配套工程");
        	}else if("300".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("公共建筑");
        	}else if("301".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("办公建筑");
        	}else if("302".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("商业建筑");
        	}else if("303".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("旅游建筑");
        	}else if("304".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("科教文卫建筑");
        	}else if("305".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("交通运输类");
        	}else if("306".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("通信建筑");
        	}else if("307".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("公共建筑配套工程");
        	}else if("400".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("商住楼");
        	}else if("500".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("农业建筑");
        	}else if("600".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("农业建筑配套工程");
        	}else if("700".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("工业建筑");
        	}else if("800".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("工业建筑配套工程");
        	}else if("999".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("其他");
        	}else if("010".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("给水");
        	}else if("011".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("排水");
        	}else if("012".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("燃气");
        	}else if("013".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("热力");
        	}else if("014".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("道路");
        	}else if("015".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("桥梁");
        	}else if("016".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("园林绿化");
        	}else if("017".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("环境卫生");
        	}else if("018".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("公共交通");
        	}else if("019".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("综合管廊");
        	}else if("020".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("隧道");
        	}else if("021".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("轨道交通");
        	}else if("099".equals(prjProject.getPrjPurpose())) {
        		prjProject.setPrjPurpose("其他");
        	}
        }
        
        //prjScale
        //项目建设规模
        //PRJ_SCALE : [{"code":"PRJ_SCALE","childrens":[{"name":"大型","dictId":"074bf14774a22445c7c5a4746e2305f9","value":"1"},
//		{"name":"中型","dictId":"8594b79b0424645f796d62f8f06b5b7c","value":"2"},
//		{"name":"小型","dictId":"f42cbc0e49889dc5d02764a4be17e148","value":"3"}],"groupId":"613b1041d4ef6b811b8779f3a87cbbd6","name":"项目建设规模"}],
        if(StringUtils.isNotBlank(prjProject.getPrjScale())) {
        	if("1".equals(prjProject.getPrjScale())) {
        		prjProject.setPrjScale("大型");
        	}else if("2".equals(prjProject.getPrjScale())) {
        		prjProject.setPrjScale("中型");
        	}else if("3".equals(prjProject.getPrjScale())) {
        		prjProject.setPrjScale("小型");
        	}
        }
		return prjProject;
	}
	
	
	@Override
	public PrjProjectEntity info(String prjId) {
		PrjProjectEntity prjProject = baseMapper.selectById(prjId);
        if(null==prjProject) {
            return null;
        }
        //查询 建设单位 项目负责人
        if(StringUtils.isNotBlank(prjProject.getBuildCorpId())) {
        	SysUserEntity user = baseMapper.projectLeaderByOrg(prjProject.getBuildCorpId(), prjProject.getPrjId(), "ROLE_JS_XMFZR");
        	if(null!=user) {
            	prjProject.setBuildProjectLeaderId(user.getUserId());
            	prjProject.setBuildProjectLeaderName(user.getRealName());
            	prjProject.setBuildCorpLinkPhone(user.getContact());
        	}
        }
        //查询 施工单位 项目负责人
        if(StringUtils.isNotBlank(prjProject.getSgCorpId())) {
        	SysUserEntity user = baseMapper.projectLeaderByOrg(prjProject.getSgCorpId(), prjProject.getPrjId(), "ROLE_SG_XMFZR");
        	if(null!=user) {
            	prjProject.setSgProjectLeaderId(user.getUserId());
            	prjProject.setSgProjectLeaderName(user.getRealName());
            	prjProject.setSgCorpLinkPhone(user.getContact());
        	}
        }
        //查询 监理单位 项目负责人
        if(StringUtils.isNotBlank(prjProject.getJlCorpId())) {
        	SysUserEntity user = baseMapper.projectLeaderByOrg(prjProject.getJlCorpId(), prjProject.getPrjId(), "ROLE_JL_XMFZR");
        	if(null!=user) {
            	prjProject.setJlProjectLeaderId(user.getUserId());
            	prjProject.setJlProjectLeaderName(user.getRealName());
            	prjProject.setJlCorpLinkPhone(user.getContact());
        	}
        }
        //查询 勘察单位 项目负责人
        if(StringUtils.isNotBlank(prjProject.getKcCorpId())) {
        	SysUserEntity user = baseMapper.projectLeaderByOrg(prjProject.getKcCorpId(), prjProject.getPrjId(), "ROLE_KC_XMFZR");
        	if(null!=user) {
            	prjProject.setKcProjectLeaderId(user.getUserId());
            	prjProject.setKcProjectLeaderName(user.getRealName());
            	prjProject.setKcCorpLinkPhone(user.getContact());
        	}
        }
        //查询 设计单位 项目负责人
        if(StringUtils.isNotBlank(prjProject.getSjCorpId())) {
        	SysUserEntity user = baseMapper.projectLeaderByOrg(prjProject.getSjCorpId(), prjProject.getPrjId(), "ROLE_SJ_XMFZR");
        	if(null!=user) {
            	prjProject.setSjProjectLeaderId(user.getUserId());
            	prjProject.setSjProjectLeaderName(user.getRealName());
            	prjProject.setSjCorpLinkPhone(user.getContact());
        	}
        }
        //查询 审图单位 项目负责人
        if(StringUtils.isNotBlank(prjProject.getStCorpId())) {
        	SysUserEntity user = baseMapper.projectLeaderByOrg(prjProject.getStCorpId(), prjProject.getPrjId(), "ROLE_ST_XMFZR");
        	if(null!=user) {
            	prjProject.setStProjectLeaderId(user.getUserId());
            	prjProject.setStProjectLeaderName(user.getRealName());
            	prjProject.setStCorpLinkPhone(user.getContact());
        	}
        }
        //查询 检测单位 项目负责人
        if(StringUtils.isNotBlank(prjProject.getJcCorpId())) {
        	SysUserEntity user = baseMapper.projectLeaderByOrg(prjProject.getJcCorpId(), prjProject.getPrjId(), "ROLE_JC_XMFZR");
        	if(null!=user) {
            	prjProject.setJcProjectLeaderId(user.getUserId());
            	prjProject.setJcProjectLeaderName(user.getRealName());
            	prjProject.setJcCorpLinkPhone(user.getContact());
        	}
        }
        //查询 预拌混凝土单位 项目负责人
        if(StringUtils.isNotBlank(prjProject.getYbhntCorpId())) {
        	SysUserEntity user = baseMapper.projectLeaderByOrg(prjProject.getYbhntCorpId(), prjProject.getPrjId(), "ROLE_YBHNT_XMFZR");
        	if(null!=user) {
            	prjProject.setYbhntProjectLeaderId(user.getUserId());
            	prjProject.setYbhntProjectLeaderName(user.getRealName());
            	prjProject.setYbhntCorpLinkPhone(user.getContact());
        	}
        }
        
		return prjProject;
	}
	
	
	
	
	
	

	
}
